import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules ,longLimtVal} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '编号',
    align:"center",
    dataIndex: 'ph',
    fixed: 'left'
   },
   {
    title: '政府编号',
    align:"center",
    dataIndex: 'zfbh',
    fixed: 'left'
   },
   {
    title: '企业名称',
    align:"center",
    dataIndex: 'mc',
    fixed: 'left'
   },
   {
    title: '签约人',
    align:"center",
    dataIndex: 'qyr',
    fixed: 'left'
   },
   {
    title: '出租方',
    align:"center",
    dataIndex: 'czf'
   },
   {
    title: '出租签约人',
    align:"center",
    dataIndex: 'czqy'
   },
   {
    title: '土地年限',
    align:"center",
    dataIndex: 'tdnx'
   },
   {
    title: '土地起始日期',
    align:"center",
    dataIndex: 'ksrq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '土地签约日期',
    align:"center",
    sorter: true,
    dataIndex: 'qyrq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '产房年限',
    align:"center",
    dataIndex: 'cfnx'
   },
   {
    title: '厂房起始日期',
    align:"center",
    dataIndex: 'ckrq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '厂房签约日期',
    align:"center",
    dataIndex: 'cqrq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '投产日期',
    align:"center",
    dataIndex: 'tcrq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '土地面积',
    align:"center",
    dataIndex: 'ttmj'
   },
   {
    title: '厂房面积',
    align:"center",
    dataIndex: 'cfmj'
   },
   {
    title: '管理费年限',
    align:"center",
    dataIndex: 'zjnx'
   },
   {
    title: '加幅',
    align:"center",
    dataIndex: 'bl'
   },
   {
    title: '土地证',
    align:"center",
    dataIndex: 'ttz'
   },
   {
    title: '房产证',
    align:"center",
    dataIndex: 'fcz'
   },
   {
    title: '制单人',
    align:"center",
    dataIndex: 'zdr'
   },
   {
    title: '付款人',
    align:"center",
    dataIndex: 'fkr'
   },
   {
    title: '投产日期',
    align:"center",
    dataIndex: 'tbrq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
  {
    title: '厂房结束日期',
    align:"center",
    dataIndex: 'ckrq1',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '土地结束日期',
    align:"center",
    dataIndex: 'tdrq1',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
   {
    title: '运行状态',
    align:"center",
    dataIndex: 'yxzt'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'bz'
   },
   {
    title: '合同文件名',
    align:"center",
    dataIndex: 'flname',
    slots: { customRender: 'flnameSlot' },
   },
/*   {
    title: 'zxxs',
    align:"center",
    dataIndex: 'zxxs'
   },*/
/*   {
    title: 'stxt',
    align:"center",
    dataIndex: 'stxtString'
   },*/
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '合同编号',
    field: 'ph',
    component: 'JInput',
  },
  {
    label: '企业名称',
    field: 'mc',
    component: 'JInput',
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'ph',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入编号!',
                 validator: (_, value) => {
                  return longLimtVal(value,14)
                },
                },
          ];
     },
    dynamicDisabled:true,
    slot: 'phSlot'
  },
  {
    label: '政府编号',
    field: 'zfbh',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,200)
          },
        },
      ];
    },
  },
  {
    label: '企业名称',
    field: 'mc',
    component: 'JSearchSelect',
    componentProps:{
      // isRadioSelection:true
      dict:"DB_QYZLB,MC,MC",
      async:true,
      pageSize:10,
    },
  },
  {
    label: '企业签约人',
    field: 'qyr',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,5)
          },
        },
      ];
    },
  },
  {
    label: '出租方',
    field: 'czf',
    component: 'JSearchSelect',
    componentProps:{
      dict:"DB_CZFB,MC,MC",
      async:true,
      pageSize:10,
    },
  },
  {
    label: '出租方签约人',
    field: 'czqy',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,5)
          },
        },
      ];
    },
  },


  {
    label: '土地起始日期',
    field: 'ksrq',
    component: 'DatePicker',
  },
  {
    label: '土地年限',
    field: 'tdnx',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        {
          validator: (_, value) => {
            return longLimtVal(value,2)
          },
        },
      ];
    },
  },
  {
    label: '土地结束日期',
    field: 'tdrq1',
    component: 'DatePicker',
  },
  {
    label: '土地签约日期',
    field: 'qyrq',
    component: 'DatePicker',
  },

  {
    label: '厂房起始日期',
    field: 'ckrq',
    component: 'DatePicker',
  },
  {
    label: '厂房年限',
    field: 'cfnx',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        {
          validator: (_, value) => {
            return longLimtVal(value,2)
          },
        },
      ];
    },
  },
  {
    label: '厂房结束日期',
    field: 'ckrq1',
    component: 'DatePicker',
  },
  {
    label: '厂房签约日期',
    field: 'cqrq',
    component: 'DatePicker',
  },
  {
    label: '投产日期',
    field: 'tcrq',
    component: 'DatePicker',
  },
  {
    label: '土地面积',
    field: 'ttmj',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,15)
          },
        },
      ];
    },
  },
  {
    label: '建筑面积',
    field: 'cfmj',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,15)
          },
        },
      ];
    },
  },
  {
    label: '管理费年限',
    field: 'zjnx',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,2)
          },
        },
      ];
    },
  },
  {
    label: '加幅',
    field: 'bl',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,15)
          },
        },
      ];
    },
  },
  {
    label: '土地证',
    field: 'ttz',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:'is_exist_certificates',
    }
  },
  {
    label: '房产证',
    field: 'fcz',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:'is_exist_certificates',
    }
  },
  {
    label: '制单人',
    field: 'zdr',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,5)
          },
        },
      ];
    },
  },
  {
    label: '付款人',
    field: 'fkr',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,5)
          },
        },
      ];
    },
  },
  {
    label: '投产日期',
    field: 'tbrq',
    component: 'DatePicker',
  },
  {
    label: '运行状态',
    field: 'yxzt',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode:'contract_state'
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择运行状态!'},
          ];
     },
  },

  {
    label: '合同文件名',
    field: 'flname',
    component: 'JUpload',
    helpMessage: '最多上传5个文件',
    componentProps: {
      maxCount: 5,
      bizPath: 'czht'
    },
  },
  {
    label: '备注',
    field: 'bz',
    component: 'InputTextArea',//TODO 注意string转换问题
    componentProps:{
      rows:10,
    }

  },
/*  {
    label: '新增显示',
    field: 'zxxs',
    component: 'JSwitch',
    componentProps:{
      options:[1,0]
    },
  },*/
/*  {
    label: 'stxt',
    field: 'stxtString',
    component: 'Input',
  },*/
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

//子表列表数据
export const dbGlfb1Columns: BasicColumn[] = [
   {
    title: '合同编号',
    align:"center",
    dataIndex: 'ph'
   },
   {
    title: '序号',
    align:"center",
    dataIndex: 'cnt'
   },
   {
    title: '付款日期',
    align:"center",
    dataIndex: 'fkrq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '工人行政费',
    align:"center",
    dataIndex: 'grgl'
   },
   {
    title: '工人行政费币种',
    align:"center",
    dataIndex: 'pz1'
   },
   {
    title: '工厂综合费',
    align:"center",
    dataIndex: 'cfgl'
   },
   {
    title: '计费面积M',
    align:"center",
    dataIndex: 'jfmj'
   },
   {
    title: '工厂综合费币种',
    align:"center",
    dataIndex: 'pz2'
   },
   {
    title: '外汇补差',
    align:"center",
    dataIndex: 'ttgl'
   },
   {
    title: '计算标准',
    align:"center",
    dataIndex: 'jsbz'
   },
   {
    title: '计费面积M',
    align:"center",
    dataIndex: 'jfmj2'
   },
   {
    title: '外汇补差币种',
    align:"center",
    dataIndex: 'pz'
   },
/*   {
    title: 'qsrq',
    align:"center",
    dataIndex: 'qsrq'
   },
   {
    title: 'zfnx',
    align:"center",
    dataIndex: 'zfnx'
   },
   {
    title: 'zfbl',
    align:"center",
    dataIndex: 'zfbl'
   },*/
];
//子表表单数据
export const dbGlfb1FormSchema: FormSchema[] = [
  {
    label: '合同编号',
    field: 'ph',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入合同编号!'},
          ];
     },
     dynamicDisabled:true,
  },
  {
    label: '序号',
    field: 'cnt',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入序号!'},
          ];
     },
  },
  {
    label: '付款日期',
    field: 'fkrq',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入付款日期!'},
          ];
     },
  },
  {
    label: '工人行政费',
    field: 'grgl',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入工人行政费!'},
                 { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
          ];
     },
  },
  {
    label: '工人行政费币种',
    field: 'pz1',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:'money_type'
    },
    defaultValue:'人民币',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入工人行政费币种!'},
          ];
     },
  },
  {
    label: '工厂综合费',
    field: 'cfgl',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入工厂综合费!'},
                 { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
          ];
     },
  },
  {
    label: '计费面积M',
    field: 'jfmj',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入计费面积!'},
                 { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
          ];
     },
  },
  {
    label: '工厂综合费币种',
    field: 'pz2',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:'money_type'
    },
    defaultValue:'人民币',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入工厂综合费币种!'},
          ];
     },
  },
  {
    label: '外汇补差',
    field: 'ttgl',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入外汇补差!'},
                 { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
          ];
     },
  },
  {
    label: '计算标准',
    field: 'jsbz',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入计算标准!'},
                 { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
          ];
     },
  },
  {
    label: '计费面积M',
    field: 'jfmj2',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入计费面积M!'},
                 { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
          ];
     },
  },
  {
    label: '外汇补差币种',
    field: 'pz',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:'money_type'
    },
    defaultValue:'人民币',
  },

];
//子表列表数据
export const dbTtfkColumns: BasicColumn[] = [
  {
    title: '收款单号',
    align:"center",
    dataIndex: 'code'
  },
  {
    title: '收款日期',
    align:"center",
    dataIndex: 'sfrq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '收款金额',
    align:"center",
    dataIndex: 'yfjg'
  },
  {
    title: '票据号码',
    align:"center",
    dataIndex: 'pjhm'
  },
  {
    title: '币制',
    align:"center",
    dataIndex: 'pz'
  },
  {
    title: '备注',
    align:"center",
    dataIndex: 'bz'
  },
];
//子表表单数据
export const dbTtfkFormSchema: FormSchema[] = [
  {
    label: '收款单号',
    field: 'code',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入收款单号!'},
      ];
    },
  },
  {
    label: '合同编号',
    field: 'ph',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入合同编号!'},
      ];
    },
    dynamicDisabled: true
  },
  {
    label: '企业名称',
    field: 'mc',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入企业名称!'},
      ];
    },
    dynamicDisabled: true
  },
  {
    label: '收款日期',
    field: 'sfrq',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入收款日期!'},
      ];
    },
  },
  {
    label: '收款金额',
    field: 'yfjg',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入收款金额!'},
      ];
    },
  },
  {
    label: '收款地址',
    field: 'fkdz',
    component: 'Input',
  },
  {
    label: '票据号码',
    field: 'pjhm',
    component: 'Input',
  },
  {
    label: '币种',
    field: 'pz',
    component: 'JDictSelectTag',
    defaultValue:'人民币',
    componentProps:{
      dictCode:'money_type'
    },
  },
  {
    label: '备注',
    field: 'bz',
    component: 'InputTextArea',
  },
];
//子表列表数据
export const dbTtgmbColumns: BasicColumn[] = [
  {
    title: '合同编号',
    align:"center",
    dataIndex: 'ph'
  },
  {
    title: '序号',
    align:"center",
    dataIndex: 'cnt'
  },
  {
    title: '收款日期',
    align:"center",
    dataIndex: 'fkrq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '单价',
    align:"center",
    dataIndex: 'dj'
  },
  {
    title: '总金额',
    align:"center",
    dataIndex: 'zjg'
  },
  {
    title: '支付比例',
    align:"center",
    dataIndex: 'zfbl'
  },
  {
    title: '支付金额',
    align:"center",
    dataIndex: 'zfjg'
  },
  {
    title: '收款金额',
    align:"center",
    dataIndex: 'fkjg'
  },
  {
    title: '币种',
    align:"center",
    dataIndex: 'pz'
  },
  {
    title: '备注',
    align:"center",
    dataIndex: 'bz'
  },
];
//子表表单数据
export const dbTtgmbFormSchema: FormSchema[] = [
  {
    label: '合同编号',
    field: 'ph',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入合同编号!'},
      ];
    },
    dynamicDisabled:true
  },
  {
    label: '序号',
    field: 'cnt',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入序号!'},
      ];
    },
  },
  {
    label: '收款日期',
    field: 'fkrq',
    component: 'DatePicker',
  },
  {
    label: '单价',
    field: 'dj',
    component: 'InputNumber',
  },
  {
    label: '总金额',
    field: 'zjg',
    component: 'InputNumber',
  },
  {
    label: '支付比例',
    field: 'zfbl',
    component: 'InputNumber',
  },
  {
    label: '支付金额',
    field: 'zfjg',
    component: 'InputNumber',
  },
  {
    label: '收款金额',
    field: 'fkjg',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入收款金额!'},
      ];
    },
  },
  {
    label: '币种',
    field: 'pz',
    component: 'JDictSelectTag',
    defaultValue:'人民币',
    componentProps:{
      dictCode:'money_type'
    },
  },
  {
    label: '类别',
    field: 'tc',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: 'landOrFactory',
    }
  },
  {
    label: '备注',
    field: 'bz',
    component: 'InputTextArea',
  },
];


//子表列表数据
export const dbCfzjbColumns: BasicColumn[] = [
  {
    title: '开始日期',
    align:"center",
    dataIndex: 'strq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '单价',
    align:"center",
    dataIndex: 'dj'
  },
  {
    title: '结费面积',
    align:"center",
    dataIndex: 'jfmj'
  },
  {
    title: '币种',
    align:"center",
    dataIndex: 'pz'
  },
];
//子表表单数据
export const dbCfzjbFormSchema: FormSchema[] = [
  {
    label: '合同编号',
    field: 'ph',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入合同编号!'},
      ];
    },
    dynamicDisabled:true,
  },
  {
    label: '序号',
    field: 'cnt',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入序号!'},
      ];
    },
  },
  {
    label: '开始日期',
    field: 'strq',
    component: 'DatePicker',
  },
  {
    label: '单价',
    field: 'dj',
    component: 'InputNumber',
  },
  {
    label: '结费面积',
    field: 'jfmj',
    component: 'InputNumber',
  },
  {
    label: '币种',
    field: 'pz',
    component: 'JDictSelectTag',
    defaultValue:'人民币',
    componentProps:{
      dictCode:'money_type'
    },
  },
/*  {
    label: 'qsrq',
    field: 'qsrq',
    component: 'Input',
  },
  {
    label: 'zfnx',
    field: 'zfnx',
    component: 'InputNumber',
  },
  {
    label: 'zfbl',
    field: 'zfbl',
    component: 'InputNumber',
  },*/
];
